home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // CaratulasDeCine+Google v1.0 by japg2000 & micmic
-
- (***************************************************
- * Author: japg2000 (japg2000@terra.es) *
- * micmic (micmic@dieznet.com) *
- * Script for the importation of pictures from *
- * caratulasdecine *
- * *
- * For use with Ant Movie Catalog 3.4.0 *
- * www.ant.be.tf/moviecatalog ╖╖╖ www.buypin.com *
- * *
- * The source code of the script can be used in *
- * another program only if full credits to *
- * script author and a link to Ant Movie Catalog *
- * website are given in the About box or in *
- * the documentation of the program *
- ***************************************************)
-
-
- program CaratulasdecineImport;
- var
- MovieName: string;
- const
- Dominio = 'www.caratulasdecine.com';
- BaseURL1 = 'http://www.google.com/custom?hl=es&ie=ISO-8859-1&cof=&domains=';
- BaseURL2 = '&q=';
- BaseURL3 = '&btnG=B%FAsqueda+en+Google&sitesearch=';
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- function EliminaInicio(S: string; CR: string): string;
- begin
- result := S;
- while Pos(CR, result) = 1 do
- begin
- Delete(result, 1, Length(CR));
- end;
- end;
-
- function CadenaEntre(var S: string; StartTag: string; EndTag: string): string;
- var
- InicioPos: Integer;
- begin
- InicioPos := Pos(StartTag, S);
- Delete(S, 1, InicioPos + Length(StartTag) - 1);
- InicioPos := Pos(EndTag, S);
- result := copy(S, 1, InicioPos - 1);
- Delete(S, 1, InicioPos + 1);
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- PosIni, PosFin: Integer;
- Line, SubLine: string;
- Title, DirURL: string;
- txtTemp: string;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- if Pos('No se encontr≤ ninguna pßgina', Page.Text) > 0 then
- begin
- ShowMessage('No se ha encontrado ning·n artφculo por tφtulo.');
- end else
- begin
- PickTreeClear;
- PickTreeAdd('Resultados de la b·squeda para "' + MovieName + '" (' + Dominio + ') por Google:', '');
-
- Page.Text := StringReplace(Page.Text, '<br>', #13#10);
- Page.Text := StringReplace(Page.Text, '<p class=g>', #13#10 + '<p class=g>');
-
- // buscamos los resultados
- LineNr := 0;
-
- while LineNr < Page.Count do
- begin
- SubLine := Page.GetString(LineNr);
- txtTemp := '<p class=g><a href=';
- PosIni := pos(txtTemp, SubLine);
- if PosIni > 0 then
- begin
- SubLine := Copy(SubLine, PosIni + Length(txtTemp), Length(SubLine));
- txtTemp := '>';
- PosFin := pos(txtTemp, SubLine);
- DirURL := Copy(SubLine, 1, PosFin - 1);
- DirURL := StringReplace(DirURL, '"', '');
-
- SubLine := Copy(SubLine, PosFin + Length(txtTemp), Length(SubLine));
- txtTemp := '</a>';
- PosFin := pos(txtTemp, SubLine);
- Title := Copy(SubLine, 1, PosFin - 1);
- HTMLRemoveTags(Title);
-
- //ShowMessage(Title + '-->' + DirURL);
- PickTreeAdd(Title, DirURL);
- end;
- LineNr := LineNr + 1;
- end;
-
- Page.Free;
- if PickTreeExec(Address) then
- AnalyzeMoviePage(Address);
- end;
- end;
-
- procedure AnalyzeMoviePage(Address: string);
- var
- MoviePage: TStringList;
- LineNr: Integer;
- Line: string;
- begin
-
- MoviePage := TStringList.Create;
- MoviePage.Text := GetPage(Address);
-
- LineNr := FindLine('<title>', MoviePage, 0);
- Line := MoviePage.GetString(LineNr);
- Line := CadenaEntre(Line, '<title>', '</title>');
- SetField(fieldTranslatedTitle, Line);
-
- LineNr := FindLine('<p align="center"><img src="', MoviePage, 0);
- Line := MoviePage.GetString(LineNr);
- Line := CadenaEntre(Line, '<p align="center"><img src="', '" ');
- Line := EliminaInicio(Line, '../');
- GetPicture('http://www.caratulasdecine.com/' + Line, True);
-
- MoviePage.Free;
- DisplayResults;
- end;
-
- // bmicmic: Bucle Principal
- begin
- if CheckVersion(3,4,0) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then MovieName := GetField(fieldTranslatedTitle);
-
- Input('Importar de ' + Dominio + ' (por Google)', 'Introduce el Titulo de la Pelicula:', MovieName);
- AnalyzePage(BaseURL1 + Dominio + BaseURL2 + UrlEncode(MovieName) + BaseURL3 + Dominio);
-
- end else
- ShowMessage('Este script necesita una versi≤n superior de Ant Movie Catalog (al menos la version 3.4.0)');
- end.
-